class UserMailer < ActionMailer::Base
  helper :application
  
  def signup_notification(user)
    setup_email(user)
    @subject    += ' Please activate your new account'
  
    @body[:url]  = "#{SITE}/activate/#{user.activation_code}"
  
  end
  
  def activation(user)
    setup_email(user)
    @subject    += ' Your account has been activated!'
    @body[:url]  = "#{SITE}/"
  end
  
  def forgot_password(user)
    setup_email(user)
    @subject    += ' You have requested to change your password'
    @body[:url]  = "#{SITE}/reset_password/#{user.password_reset_code}"
  end
 
  def reset_password(user)
    setup_email(user)
    @subject    += ' Your password has been reset.'
  end

  def registration_confirmation(user, password, from_email='paul@redjamjar.net', subject='Thankyou for registering')
    recipients    user.email
    from          from_email
    subject       subject
    body          :user => user, :mypassword => password
  end
  
  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = "paul@redjamjar.net"
      @subject     = "Squash Ladder: "
      @sent_on     = Time.now
      @body[:user] = user
    end
end
